<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <title>Title</title>
    </head>
    <body></body>
    <script>
        "use strict";

        const createPromise = function(bool) {
            return new Promise((resolve, reject) => {
                if (bool) {
                    resolve("我们成功了");
                } else {
                    reject("还是失败了");
                }
            });
        };

        createPromise(true).then(
            function(value) {
                console.log(value);
            },
            function(error) {
                console.log(error);
            }
        );

        createPromise(false).then(
            function(value) {
                console.log(value);
            },
            function(error) {
                console.log(error);
            }
        );

        createPromise(false).then(
            function(value) {
                console.log(value);
            },
            [123]
        );

        createPromise(false).then(null, function(error) {
            console.log(error); //还是失败了
        });

        createPromise(false).then(undefined, function(error) {
            console.log(error); //还是失败了
        });

        createPromise(false).then([1, 2, 3], function(error) {
            console.log(error); //还是失败了
        });

        createPromise(false).then({ a: "1" }, function(error) {
            console.log(error); //还是失败了
        });

        createPromise(false).then("刘德华", function(error) {
            console.log(error); //还是失败了
        });
    </script>
</html>
